// 接口统一管理
import requests from "./request";
// mock 请求数据
import mockRequest from './mockRequest.js'

export const reqCategoryList = () => requests({url: '/product/getBaseCategoryList', method: 'get'})
  // 返回的是promise对象
  
export const reqGetBannerList = () => mockRequest({url: '/banner', method: 'get'})

export const reqGetFloorList = () => mockRequest({url:'/floor', method: 'get'})

// 获取搜索模块数据地址 /api/list  post  参数：如下
/*
{
  "category3Id": "61",
  "categoryName": "手机",
  "keyword": "小米",
  "order": "1:desc",
  "pageNo": 1,
  "pageSize": 10,
  "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
  "trademark": "4:小米"
}
*/
export const reqGetSearchInfo = (params) => requests ({url: '/list', method: 'post', data: params})

// 详情页发请求
export const reqGoodsInfo = (skuId) => requests ({url: `/item/${skuId}`, method: 'get'})

// 详情页加入购物车post请求 带参skuId skuNum
export const reqAddOrUpdateShopCart = (skuId, skuNum) => requests ({url:`/cart/addToCart/${skuId}/${skuNum}`, method: 'post'})

// 获取购物车数据列表
export const reqCartList = () => requests ({url: '/cart/cartList', method: 'get'})

// 购物车删除商品
export const reqDeleteCartById = (skuId) => requests ({url: `/cart/deleteCart/${skuId}`, method: 'delete'})

// 修改购物车商品选中状态
export const reqUpdateCheckedById = (skuId, isChecked) => requests ({url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get'})

// 获取注册验证码
export const reqGetCode = (phone) => requests ({url: `/user/passport/sendCode/${phone}`, method: 'get'})

// 完成注册请求
export const reqUserRegister = (data) => requests ({url:'/user/passport/register', data: data, method: 'post'})

// 登录请求
export const reqUserLogin = (data) => requests ({url: '/user/passport/login', data, method: 'post'})

// 获取用户信息请求（需要请求头带着用户token向服务器要用户信息）
export const reqUserInfo = () => requests ({url: '/user/passport/auth/getUserInfo', method: 'get'})

// 退出登录
export const reqLogout = () => requests ({url: '/user/passport/logout', method: 'get'})

// trade页面获取用户地址信息
export const reqAddressInfo = () => requests ({url: '/user/userAddress/auth/findUserAddressList', method: 'get'})

// trade页面获取商品清单
export const reqOrderInfo = () => requests ({url: '/order/auth/trade', method: 'get'})

// trade页面提交订单请求 /order/auth/submitOrder?tradeNo={tradeNo}  post
export const reqSubmitOrder = (tradeNo, data) => requests ({url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: 'post'})

// pay页面获取支付信息请求
export const reqPayInfo = (orderId) => requests ({url: `/payment/weixin/createNative/${orderId}`, method: 'get'})

// 获取支付订单状态
export const reqPayStatus = (orderId) => requests ({url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get'})

// 获取个人中心我的订单 get
export const reqMyOrderList = (page, limit) => requests ({url: `/order/auth/${page}/${limit}`, method: 'get'})